<?php
$T->loadTpl("./html/".$template."/".$qname.".html");
$T->SetTpl('cssjs','html/cssjs.inc'); 
$T->SetTpl('jsmodel','html/jsmodel.inc');     
  
$rid=$_SESSION["role"];
$r_sql="";
$a_sql="";
$b_sql="";
$c_sql="";
if(ckAdm()){
    $r_sql="select * from sys_menu where pid=0 and flag=0 order by odx asc";
    $a_sql="select count(1) from sys_announce  order by time desc limit 1";
    $b_sql="select id as a_id,content as a_content,time as a_time from sys_announce order by time desc limit 1";
    $c_sql="select * from sys_announce order by time desc limit 8";
}else{
    $menuid=$T->db->query("select menu_id from sys_role_menu where rid=".$rid)->fetch(PDO::FETCH_ASSOC);
    $r_sql="select * from sys_menu where pid=0 and id in (select distinct pid from sys_menu where id in (".$menuid["menu_id"].")) order by odx asc";

    $a_sql="select count(1) from sys_announce where locate('".$_SESSION['school']."',acceptsch)>0 order by time desc limit 1";
    $b_sql="select id as a_id,content as a_content,time as a_time from sys_announce where locate('".$_SESSION['school']."',acceptsch)>0 order by time desc limit 1";
    $c_sql="select * from sys_announce where locate('".$_SESSION['school']."',acceptsch)>0 order by time desc limit 8";
}
$T->SetBlock("tp_menu",$r_sql);
//置顶公告
$isannounce = $T->db->query($a_sql)->fetchColumn(0);
if($isannounce){
    $T->Set("isannounce",$isannounce);
    $T->readDB($b_sql);
}
$a_html='';
$alist = $T->db->query($c_sql)->fetchAll(PDO::FETCH_ASSOC);
foreach ($alist as $k => $val) {
    $content = strip_tags($val['content']);
    $a_html.='<li data-id="'.$val["id"].'" class="ellipsis announce hand" style="width:500px;text-align:left;">'.$content.'</li><hr>';
}
$T->Set("a_html",$a_html);
$T->Set("uname",$_SESSION["nick"]);

$T->Set("template",$template);         
$T->clearNaN();       
$T->clearNoN();
$T->display();  